(function($f) {	$f.extend.custom("myPlugin1", function(self) {

	"use strict";
	
	// plugin info
	this.info = {
		title: "My Plugin 1",
		version: "0.0.1" // major.minor.build
	};

	// load a plugin dynamically
	this.loadPlugin = function() {
		if ($f.has.feature("dynamicExtend")) {
			if (!$f.myPlugin2) {
				// load plugin programatically
				$f.extend.fromFile("./plugins/myPlugin2.debug.js", "myPlugin2", function(data, isError) { 
					if (!isError) {
						$f.alert($f.myPlugin2.info.title + " is available now.");
					} else {
						$f.alert("Plugin could not be loaded.");
					};
				});
			} else {
				$f.alert($f.myPlugin2.info.title + " is already loaded.");
			};
		} else {
			$f.alert("'dynamicExtend' feature is not available.");
		};
	};

	// load a feature dynamically
	this.loadFeature = function() {
		if ($f.has.feature("dynamicExtend")) {
			if (!$f.has.featureDefinition("myFeature1")) {
				// load feature programatically
				$f.extend.feature.fromFile("./features/myFeature1.debug.js", function(data, isError) { 
					if (!isError) {
						$f.alert("myFeature1 is available now.");
					} else {
						$f.alert("Feature could not be loaded.");
					};
				});
			} else {
				$f.alert("myFeature1 is already loaded.");
			};
		} else {
			$f.alert("'dynamicExtend' feature is not available.");
		};
	};
	
	// show plugins list
	this.showPluginsList = function() {
		var div = $("#list");
		
		// load plugins list
		var list = "<table class='table table-bordered'><tr><th align='left'>Name</th><th align='left'>Id</th><th align='left'>Version</th><th align='left'>Description</th></tr>";
		$.each($f.all.plugins(), function(i, plugin) {
			var className = ($f.utils.string.startsWith(plugin.handle.name, "myPlugin") ? "info" : "");
			list += "<tr class='" + className + "'><td style='vertical-align: top'>" + plugin.handle.name + 
				    "</td><td>" + plugin.handle.id + 
					"</td><td>" + plugin.info.version.version + 
					"</td><td>" + plugin.info.description + 
					"</td></tr>";
		});
		list += "</table>";
		div.empty().append(list);
	};
}); }(fluid));
